<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // 扩展运算符  ... 
    // 合并数组  ...扩展运算符 可以实现数组的深拷贝
    var arr1 = [["a", { c: 8 }], 2, 3]
    var arr2 = [4, 5, 6]
    var arr3 = [...arr2, ...arr1, 7, 8, 9]
    console.log(arr3)
    arr3[3] = ["e", { c: 9 }];
    console.log(arr1[0])

    // 合并对象  ...扩展运算符 合并对象  浅拷贝 只复制第一层数据
    var obj1 = {
      name: {
        k: "kky"
      },
      age: 2
    }
    var obj2 = {
      sex: 3,
      shengao: 4,
      ...obj1
    }
    var obj3 = {
      ...obj2,
      hobby: 88
    }
    console.log(obj3)
    obj3.name.k = "赛道和发";
    obj3.age = 88;
    console.log(obj1.name.k)
    console.log(obj1.age)
    // 深拷贝方式
    // 1.JSON.parse(JSON.stringify()
    // 2.递归函数 递归去拷贝数据

  </script>
</body>

</html>